home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / csim / source.lha / source / C++SIM / thread.h < prev   
C/C++ Source or Header  |  1993-06-14  |  1KB  |  48 lines

  1. /*
  2.  * Copyright (C) 1993
  3.  *
  4.  * Department of Computing Science,
  5.  * The University,
  6.  * Newcastle upon Tyne,
  7.  * UK.
  8.  */
  9.  
  10. #ifndef THREAD_H_
  11. #define THREAD_H_
  12.  
  13. /* This class defines a template for threads packages which will be used to
  14.  * provide "active" objects in C++. Such objects are not derived from this
  15.  * class, but instead a thread implementation class is derived from this.
  16.  * That class will then define the pure virtual functions, and "active" objects
  17.  * are then derived from that class.
  18.  * Because not every thread package provides an easy way of identifying and locating
  19.  * threads, the Thread class does provide such a scheme through the use of the
  20.  * Identify and Self operations. A linked list of threads is formed and added to
  21.  * whenever a new thread is created.
  22.  */
  23.  
  24. class Thread
  25. {
  26. public:
  27.     virtual void Suspend () = 0; // How to suspend a thread
  28.     virtual void Resume () = 0; // How to resume a suspended thread
  29.     virtual void Body () = 0; // The 'main' part of the code
  30.  
  31.     virtual long Current_Thread () const = 0; // Should return some unique thread identity key
  32.  
  33.     virtual long Identity () const; // Returns the identify of this thread
  34.     static Thread *Self (); // Returns the current thread
  35.  
  36. protected:
  37.     Thread ();
  38.     virtual ~Thread ();
  39.  
  40.     long thread_key;
  41.  
  42. private:
  43.     Thread *next, *prev;
  44.     static Thread *head;
  45. };
  46.  
  47. #endif
  48.